---
title: "API Reference: Inline Trace Plugin"
api_reference: true
---

## Using the plugin

> 📣 **New since Apollo Server 4**: error details are not included in traces by default. For more details, see [Error Handling](../../data/errors/#masking-and-logging-errors).

This article documents the options for the `ApolloServerPluginInlineTrace` plugin, which you can import from `@apollo/server/plugin/inlineTrace`.

This plugin enables your GraphQL server to include encoded performance and usage traces inside responses. This is primarily designed for use with [Apollo Federation](/federation/metrics/). Federated subgraphs use this plugin and include a trace in the `ftv1` GraphQL response extension if requested to do so by the Apollo gateway. The gateway requests this trace by passing the HTTP header `apollo-federation-include-trace: ftv1`.

Apollo Server installs this plugin by default in all federated subgraphs, with its default configuration—masking `errors` and `extensions` (see [Options](#options) for more details). Apollo Server inspects whether or not the schema it is serving includes a field `_Service.sdl: String!` (as well as its former, nullable version from Federation v1: `_Service.sdl: String`) to determine if it is a federated subgraph. You typically do not have to install this plugin yourself; you only need to do so if you want to provide non-default configuration.

If you want to configure the `ApolloServerPluginInlineTrace` plugin, import it and pass it to your `ApolloServer` constructor's `plugins` array:

<MultiCodeBlock>

```ts
import { ApolloServer } from '@apollo/server';
import { ApolloServerPluginInlineTrace } from '@apollo/server/plugin/inlineTrace';

const server = new ApolloServer({
  typeDefs,
  resolvers,
  plugins: [
    ApolloServerPluginInlineTrace({
      includeErrors: { transform: (err) => (err.message.match(SENSITIVE_REGEX) ? null : err ) },
    }),
  ],
});
```

</MultiCodeBlock>

If you don't want to use the inline trace plugin even though your schema defines `_Service.sdl: String!`, you can explicitly disable it with the `ApolloServerPluginInlineTraceDisabled` plugin:

<MultiCodeBlock>

```ts
import { ApolloServer } from '@apollo/server';
import { ApolloServerPluginInlineTraceDisabled } from '@apollo/server/plugin/disabled';

const server = new ApolloServer({
  typeDefs,
  resolvers,
  plugins: [
    ApolloServerPluginInlineTraceDisabled(),
  ],
});
```

</MultiCodeBlock>

Note that when this plugin is installed in your app, any client can request a trace for any operation they run, which may reveal information about your server that you consider sensitive (such as how long each individual field takes to execute). Federated subgraphs generally should not be directly exposed to the public Internet.

When using Federation, you typically run this plugin in subgraphs and you run the usage reporting plugin in gateways; this is how the default behavior works. If you include this plugin in a gateway, then the gateway will include a full trace including the query plan and all subgraph traces inline in its responses. This is not recommended for publicly exposed servers, but can be helpful when developing locally if you want to see the exact query plan generated by your gateway.

## Options

<table class="field-table">
  <thead>
    <tr>
      <th>Name /<br/>Type</th>
      <th>Description</th>
    </tr>
  </thead>

<tbody>

<tr>
<td>

###### `includeErrors`

`Object`
</td>
<td>

Provide this object to modify GraphQL operation errors before your server reports those errors in traces to Apollo Studio. Valid options are described in [Valid `includeErrors` object signatures](#valid-includeerrors-object-signatures).

The default value is `{ masked: true }`, which means error messages are masked and extensions are omitted. This is a security measure to prevent sensitive data from potentially reaching Apollo servers.
</td>
</tr>

</tbody>
</table>


#### Valid `includeErrors` object signatures

<table class="field-table">
  <thead>
    <tr>
      <th>Object</th>
      <th>Description</th>
    </tr>
  </thead>

<tbody>

<tr>
<td>

###### `{ masked: true }`

</td>
<td>

If you provide this object, error messages are masked and extensions omitted in the traces sent to Apollo Studio.  This is the default behavior.

</td>
</tr>

<tr>
<td>

###### `{ unmodified: true }`

</td>
<td>

If you provide this object, all error messages and extensions are included in traces

</td>
</tr>

<tr>
<td>

###### `{ transform: (err: GraphQLError) => GraphQLError | null }`

</td>
<td>

The value of `transform` is a function that receives each error (`GraphQLError`) and must also return a `GraphQLError` object (or `null` to prevent Apollo Server from reporting a particular error entirely).

The only properties of the reported error you can modify are its `message` and its `extensions`. See [Masking and logging errors](../../data/errors/#masking-and-logging-errors) for more details.
</td>
</tr>


</tbody>
</table>

